############################################################################################################
soc_vars_2 = c('L.L28_Community.work','L.L38_Community.meeting')

set.seed(1000)
ind_pca_2 = prcomp( ~ L.L28_Community.work+L.L38_Community.meeting, data = A, scale = T)
#first component is just sqrt(2)/2 of both items, ie root sum square

summary(ind_pca_2)
-ind_pca_2$rotation
plot(ind_pca_2$sdev)
title('All-Waves PCA Std. Dev.')

#add to main data frame
A[which(complete.cases(A[,soc_vars_2])),'AltSocDens'] = -ind_pca_2$x[,1]

rm(soc_vars_2, ind_pca_2)